
using OfficeOpenXml;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using System;
using HHHFramework;

public class ExcelEditor: MonoBehaviour
{
    public Dictionary<string, System.Object> testDic=new Dictionary<string, object>();
    void LoadTest() {
        string tissueOldPath = Application.streamingAssetsPath + "/ExcelV4.0/OldTissue.xlsx";
        LoadTissueExcel(tissueOldPath, "Sheet", testDic, () => { });
    }
   
    void LoadTissueExcel<T>(string path, string WorksheetName, Dictionary<string, T> testDic, Action callBack)
    {
        SaveManager.LoadExcelData(path, WorksheetName, (excelWorksheet) =>
        {
            Debug.Log(path);
            object[,] cells = excelWorksheet.Cells.Value as object[,];
            string key ="";
            for (int rowIndex = 1; rowIndex < cells.GetLength(0); rowIndex++)
            {
                key = cells[rowIndex, 0].ToString();
                T t = default;
                //AcupointTableData acupoint = new AcupointTableData
                //{
                //    chineseName = cells[rowIndex, 0].ToString(),
                //    englishName = cells[rowIndex, 1].ToString(),
                //    meridianName = cells[rowIndex, 2].ToString(),
                //    infoWord = cells[rowIndex, 3].ToString(),
                //    isDanger = cells[rowIndex, 4].ToString() == "true" ? true : false,
                //    isProhibit = cells[rowIndex, 5].ToString() == "true" ? true : false,
                //    path = cells[rowIndex, 6].ToString(),
                //    anatomy = cells[rowIndex, 7].ToString(),
                //};

                testDic.Add(key, t);
            }
        });

        callBack?.Invoke();
    }

}

public class CreateScriptable
{
    public static void CreateMenuThreeLayerData<T>(List<T> systemNameArray,string bodySystem)
    {
        //自动创建scriptable
        //MenuThreeLayerData direction = ScriptableObject.CreateInstance<MenuThreeLayerData>();
        //direction.systemNameArray = systemNameArray;
        //direction.DataIni();
        //direction.bodySystemUrogenitalSystemWoman = bodySystem;

        //AssetDatabase.CreateAsset(direction, "Assets/Resources/MenuThreeLayerData.asset");
        ////保存Asset" MenuThreeLayerData.asset"
        //AssetDatabase.SaveAssets();
    }
}